import "package:flutter/material.dart";
import 'package:flutter_pink_app/serialized/profile.dart';
import 'package:flutter_pink_app/style/decoration.dart';
import 'package:flutter_pink_app/style/text.dart';

// 番剧卡片
class AnimateCard extends StatelessWidget {
  final AnimatedInfo _info; // 动画详细信息
  final double height; // 高度
  final double width; // 宽度
  final double cardRadius; // 卡片圆角半径
  final VoidCallback onTap; // 点击触发函数

  const AnimateCard(this._info,
      {Key key, this.height, this.width, this.onTap, this.cardRadius = 5})
      : super(key: key);

  // 构建浮动文字
  Padding _buildFloatText(String content) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 3),
      child: Text(content,
          style: focusWhiteStyle, overflow: TextOverflow.ellipsis),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: ClipRRect(
        borderRadius: BorderRadius.circular(cardRadius),
        child: SizedBox(
          height: height,
          width: width,
          child: Stack(
            children: <Widget>[
              Image.network(_info.cover, fit: BoxFit.cover),
              Positioned(
                bottom: 0,
                left: 0,
                right: 0,
                child: Container(
                  padding: const EdgeInsets.only(top: 20),
                  decoration: BoxDecoration(gradient: blackLinearGradient()),
                  child: Column(
                    children: <Widget>[
                      _buildFloatText(_info.name),
                      _buildFloatText("已完结"),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
